define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'jizhan.offline_order/index',
        add_url: 'jizhan.offline_order/add',
        edit_url: 'jizhan.offline_order/edit',
        delete_url: 'jizhan.offline_order/delete',
        export_url: 'jizhan.offline_order/export',
        modify_url: 'jizhan.offline_order/modify',
        detail_url: 'jizhan.store_order/detail',
        deal_url: 'jizhan.store_order/deal',
    };
    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh', 'export'],
                cols: [[
                    // 订单号|类型,用户昵称|ID|代理等级,商品名称,规格,购买数量,下单基站,下单时间,销售价,优惠金额,实际支付,返利积分,支付方式,订单 状态,完成时间
                    {type: "checkbox"},
                    {field: 'id', title: '订单ID', search: 'no'},
                    {field: 'orderSn', width: 190, title: '订单号|类型', search: 'no'},
                    {field: 'userInfo', width: 180, title: '用户昵称|ID|代理等级', search: 'no'},
                    {field: 'productInfo', minWidth: 330, title: '商品信息', search: 'no'},
                    {field: 'storeName', minWidth: 120, title: '下单基站', selectList: storeList},
                    {field: 'add_time', minWidth: 160, title: '下单时间', search: 'range'},
                    {field: 'price', minWidth: 80, title: '销售价', search: 'no'},
                    {field: 'deduction_price', minWidth: 120, title: '优惠金额', search: 'no'},
                    {field: 'pay_price', minWidth: 120, title: '实际支付', search: 'no'},
                    {field: 'gain_integral', minWidth: 120, title: '返利积分', search: 'no'},
                    {field: 'payType', minWidth: 80, title: '支付方式', selectList: payType},
                    {field: 'orderStatus', minWidth: 80, title: '订单状态', selectList: orderStatus},
                    {width: 250, title: '操作', templet: ea.table.tool,operat: [
                            [{
                                text: '订单详情',
                                url: init.detail_url,
                                method: 'open',
                                auth: 'detail',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            },{
                                text: '订单操作',
                                url: init.deal_url,
                                method: 'open',
                                auth: 'deal',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: '',
                            }]
                        ]}
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        detail: function () {
            ea.listen();
        },
        deal: function () {
            ea.listen();
        },
    };
    return Controller;
});